package com.github.willisaway.core.inter;

import java.util.List;

/**
 * 为了适配不同的树的统一操作
 * @author liyougen
 *
 * @param <T>
 */
public interface TreeNode<T> {
    public T getNodeId();
    
    public String getNodeName();
    
    public T getParentNodeId();
    
    public List<TreeNode<T>> getNodeChilds();
    
    public void setNodeChilds(List<TreeNode<T>> childs);
    
    public default boolean idEquals(Object id1,Object id2) {
        if(getNodeId() instanceof Long) {
            return ((Long)id1).longValue() == ((Long)id2).longValue();
        }else if(getNodeId() instanceof Integer) {
            return ((Integer)id1).intValue() == ((Integer)id2).intValue();
        }else if(getNodeId() instanceof String) {
            return ((String)id1).equals((String)id2);
        }
        return id1.equals(id2);
    }
}
